<template>
  <div>
    <div class="form-content" v-if="statusListingTidy" :key="1">
      <p>2.0清单整理</p>
      <el-form ref="form" class="form-input" :model="formData" label-width="120px" :rules="ruleData">

        <el-row>
          <el-form-item label="意见">
            <el-input type="textarea" v-model="formData.opinion"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="下一流程">
              <el-input v-model="nextNodeNameContent" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下一流程人员" prop="nextAuthor">
              <el-select placeholder="请选择下一流程人员" v-model="formData.nextAuthor" multiple @change="handleChange">
                <el-option v-for="item in nextAuthorLists" :key="item.id" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="btn-option">
          <el-button type="primary" @click="submit">提交</el-button>
          <el-button @click="cancel">取消</el-button>
        </div>
      </el-form>
    </div>

    <div class="form-content" v-else :key="2">
      <p>2.0清单整理2</p>
      <!-- <el-form class="form-input" :model="formData2" label-width="120px">
        <el-row>
          <el-form-item label="备注">
            <el-input type="textarea" v-model="formData2.remarks" readonly></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="下一流程">
              <el-input v-model="nextNodeNameContent" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下一流程人员">
              <el-input v-model="formData2.nextAuthor" readonly></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form> -->
    </div>
  </div>
</template>
<script>
import { EmbodimentCreate } from '@/api/api'
import { nextNodeArr, getName, getMultipleLabel, getFileId, downfile } from '@/unils/utils'
import Bus from '@/plugins/bus'
import swal from 'sweetalert'
import _ from 'underscore'
import uploadFile from "@/view/audit/flow/upload"
export default {
  props: {
    listingTidyId: {
      type: String,
      defalut: ''
    },
    nodeIdId: {
      type: [String, Number],
      defalut: 2
    },
    statusListingTidy: {
      type: Boolean,
      defalut: true
    }
  },
  components: {
    UploadFile: uploadFile,
  },
  data () {
    return {
      orunid: '',
      formData: {
        opinion: '',
        nextAuthor: [],
      },
      labelName: '',
      nextAuthorLists: [],
      nextNodeNameContent: '2.1清单审核',
      ruleData: {
        nextAuthor: [{ required: true, message: '请选择下一流程人员!', trigger: 'change' }]
      },
      // formData2: {
      //   complete1: false,
      //   complete2: false,
      //   remarks: '',
      //   nextAuthor: '',
      //   addName: '',
      //   file1: [],
      //   file2: []
      // },
    };
  },
  mounted () {
    
  },
  beforeDestroy () {
    // Bus.$off('res')
    // Bus.$off('resAuthor')
  },
  methods: {
    handleChange (val) {
      this.labelName = getMultipleLabel(val, this.nextAuthorLists)
    },
    // 文件操作
    // getfiles1 (e) {
    //   this.formData.file1 = e
    // },
    // getfiles2 (e) {
    //   this.formData.file2 = e
    // },
    // downFile1 (id) {
    //   downfile(id)
    // },
    // downFile2 (id) {
    //   downfile(id)
    // },
    submit: _.debounce(async function () {
      await this.$refs.form.validate(async (valid) => {
        if (!valid) return false
        let msg = '是否确认提交!'
        // if (this.formData.file1.length == 0 || this.formData.file2.length == 0) {
        //   msg = '检测到有文件没提交，是否确认提交!'
        // }
        // await this.confirm(msg, async () => {
        //   let file1Obj = await getFileId(this, this.formData.file1, 1, 5)
        //   let file2Obj = await getFileId(this, this.formData.file2, 1, 5)
        //   let params = {
            
        //   }
        //   EmbodimentCreate(params)
        //     .then((res) => {
        //       // console.log(res)
        //       if (res.code == 200) {
        //         this.alertok('提交成功', () => {
        //           this.$router.go(-1)
        //         })
        //       } else {
        //         swal('错误', res.message || '网络连接错误', 'warning')
        //       }
        //     })
        //     .catch((err) => {
        //       swal('错误', '网络连接错误', 'error')
        //     })
        // })
      })
    }),
    cancel () {
      this.$router.go(-1)
    },
  },
};
</script>
<style lang="less" scoped>
.form-content {
  font-size: 30px;
  p {
    text-align: center;
    margin-bottom: 40px;
  }
  .form-input {
    width: 70%;
    margin: auto;
    .btn-option {
      display: flex;
      justify-content: flex-end;
    }
  }
}
</style>